package com.wxmp.wxapi.service.impl;

import com.wxmp.wxapi.service.IAccountService;
import com.wxmp.wxapi.service.PushService;
import com.wxmp.wxapi.util.CaiHongPi;
import com.wxmp.wxapi.util.Pusher;
import com.wxmp.wxcms.domain.Account;
import com.wxmp.wxcms.domain.AccountFans;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Optional;

/**
 * @Author zzm
 * @Date 2022/8/23 13:53
 * @Version 1.0
 **/
@Service("night")
public class NightPushServiceImpl implements PushService {

    @Resource
    private Map<String, IAccountService> accountServiceMap;


    @Override
    public void push(AccountFans accountFans, String templateId, Account account) {
        IAccountService accountService = Optional.ofNullable(accountServiceMap.get(account.getName())).orElse(accountServiceMap.get("default"));
        accountService.pushNightMessage(accountFans, templateId, account);
    }
}
